package logic

import (
	"context"
	"fmt"
	"regi/models"

	"regi/regirpc/internal/svc"
	"regi/regirpc/regirpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RegiShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRegiShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegiShowLogic {
	return &RegiShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情
func (l *RegiShowLogic) RegiShow(in *regirpc.RegiShowRequest) (*regirpc.RegiShowResponse, error) {
	// todo: add your logic here and delete this line

	var regi models.Regi

	if err := regi.RegiShowById(models.Regi{}, in.RegiId); err != nil {
		return nil, fmt.Errorf("当前患者不存在,查询失败")
	}

	return &regirpc.RegiShowResponse{
		Name:     regi.Name,
		HospName: regi.HospName,
		DepName:  regi.DepName,
		Tel:      regi.Tel,
		RegiId:   int64(regi.ID),
	}, nil
}
